package com.cimp.service.user;

import com.cimp.dao.user.IUserDao;
import com.cimp.domain.user.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserService implements IUserService{

    @Resource
    private IUserDao userDao;

  //登录验证
    @Override
    public User loginUser(String userName, String password) {
        //根据用户名查用户

        User user = userDao.selectUserByName(userName);
        //根据查询结果返回不同对象
        if(user==null){
            return null;
        }else{//对比密码
            String queryPassword = user.getPassword();
            if(queryPassword.equals(password)){
                return user;
            }else{
                return null;
            }

        }
    }
}
